package structure.flyweight;

import java.util.HashMap;
import java.util.Map;

/**
 * 对象存储工厂
 */
public class ShapeFactory {
	public static final Map<String,Shape> shapeMap = new HashMap<>();
	
	public static Shape getShape(String shapeName){
       Shape shape = shapeMap.get(shapeName);
       if(shape == null){
    	   if("circle".equals(shapeName)){
    		   shape = new Circle();
    		   shapeMap.put("circle", shape);
    	   }
       }
       return shape;      
	}
}
